<template>
  <div>
    <el-table :data="x" v-for="x in tableData" :key="x.uid" style="width: 100%">
      <el-table-column type="selection" width="55" align="center">
      </el-table-column>
      <el-table-column label="编号" width="180" align="center">
        <template slot-scope="scope">
          <!-- <i class="el-icon-time"></i> -->
          <span style="margin-left: 10px">{{ scope.row.uid }}</span>
        </template>
      </el-table-column>

      <el-table-column label="姓名" width="180" align="center">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <p>姓名: {{ scope.row.uname }}</p>
            <p>密码: {{ scope.row.upwd }}</p>
            <div slot="reference" class="name-wrapper">
              <el-tag size="medium">{{ scope.row.uname }}</el-tag>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="手机号" width="180" align="center">
        <template slot-scope="scope">
          <!-- <i class="el-icon-time"></i> -->
          <span style="margin-left: 10px">{{ scope.row.uphone }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template>
          <el-button size="mini" @click="dialogVisible = true">编辑</el-button>
          <el-button
            size="mini"
            type="danger"
            @click="centerDialogVisible = true"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <div>
      <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
        <span>这是一段信息</span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogVisible = false"
            >确 定</el-button
          >
        </span>
      </el-dialog>
      <el-dialog
        title="提示"
        :visible.sync="centerDialogVisible"
        width="30%"
        center
      >
        <span>需要注意的是内容是默认不居中的</span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="centerDialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="centerDialogVisible = false"
            >确 定</el-button
          >
        </span>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogVisible: false,
      tableData: [],
      centerDialogVisible: false,
    };
  },
  methods: {
    getData() {
      this.axios
        .get("http://127.0.0.1:3000/data/users/rootuser")
        .then((res) => {
          this.tableData.push(res.data.data);
        });
    },
  },
  mounted() {
    this.getData();
  },
};
</script>

<style lang="scss"></style>
